﻿@{
}
@section head {
    <link type="text/css" href="~/static/css/portlet.css" rel="stylesheet" />
    <script type="text/javascript" src="~/static/js/minifox.ui.js"></script>
    <script type="text/javascript" src="~/static/js/portlet.js"></script>
    <script type="text/javascript" src="~/static/js/echarts.min.js"></script>
    <script type="text/javascript">

        $(function () {

            var portlet = new MiniFox.Portlet({
                element: "#portlet",
                editMode: false,
                replaceMode: true,
                created: function () {
                    var portlet = this;

                    MiniFox.http({
                        url: "@(Url.Action("widgets"))",
                    }).then(function (response) {
                        if (response.success) {
                            response.data.forEach(function (task) {
                                portlet.createWidget({
                                    id: task.name,
                                    name: `name-${task.name}`,
                                    title: task.title,
                                    icon: task.icon,
                                    colSpan: task.colSpan,
                                    rowSpan: task.rowSpan,
                                    className: task.className,
                                    enterUrl: task.enterUrl,
                                    showHeader: task.showHeader,
                                    showFooter: task.showFooter,
                                    template: "#tmpl_widget",
                                    schedule: task.schedule ? { delay: task.schedule.delay, once: task.schedule.once, interval: task.schedule.interval } : null,
                                    dataSource: task.dataSource ? {
                                        url: task.dataSource.url,
                                        method: task.dataSource.method,
                                        headers: task.dataSource.headers,
                                        params: task.dataSource.params,
                                        data: task.dataSource.data
                                    } : null,
                                    dataTemplate: task.template,
                                    script: task.script
                                });
                            });
                        }
                    });
                }
            });
        });
    </script>
}
<template id="tmpl_widget">
    <div class="widget col-sm-${colSpan} row-${rowSpan}">
        <div class="panel ${className}">
            {{if showHeader}}
            <div class="panel-heading">
                <h3 class="panel-title"><i class="${icon}"></i> ${title}</h3>
            </div>
            {{/if}}
            <div id="${name}" class="panel-body data-content">

            </div>
            {{if showFooter}}
            <div class="panel-footer">
                <a class="more" href="#" data-target="module" data-url="${enterUrl}" data-icon="${icon}" title="${title}">
                    查看更多
                </a>
            </div>
            {{/if}}

        </div>
        {{if editMode}}
        <div class="editMode">
            <div class="tool">
                <div class="pull-right">
                    <a href="#">
                        <i class="glyphicon glyphicon-cog"></i>
                    </a>
                    <a href="#">
                        <i class="glyphicon glyphicon-remove"></i>
                    </a>
                </div>
            </div>
        </div>
        {{/if}}
    </div>
</template>
<div id="portlet" class="container-fluid portlet">
</div>